package exception;

// 异常类
class AgeException extends Exception{
	public AgeException(){
		super("非法年龄");
	}
}
/**
 * 自定义异常
 */
public class Test4 {
	
	public static void main(String[] args) {
		int age=188;
		try {
			if(age<0 || age>120){
				throw new AgeException();
			}
			System.out.println("你的年龄"+age);
		} catch (AgeException e) {
			System.out.println("处理"+ e.getMessage());
		}
	}

}
